package cn.edu.sdjzu.xg.eagle.service.impl;

import cn.edu.sdjzu.xg.eagle.entities.Statistics;
import cn.edu.sdjzu.xg.eagle.mapper.StatisticsMapper;
import cn.edu.sdjzu.xg.eagle.service.inface.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

@Service
public class StatisticsServiceImpl implements StatisticsService {

    @Autowired
    private StatisticsMapper statisticsMapper;

    @Override
    public String addStatistic(Statistics statistic) throws SQLException {
        if (statisticsMapper.addStatistic(statistic)) {
            return "添加统计数据成功";
        }
        return "添加统计数据失败";
    }

    @Override
    public String deleteStatistic(int statisticId) throws SQLException {
        if (statisticsMapper.deleteStatistic(statisticId)) {
            return "删除统计数据成功";
        } else {
            return "删除统计数据失败";
        }
    }

    @Override
    public String updateStatistic(Statistics statistic) throws SQLException {
        if (statisticsMapper.updateStatistic(statistic)) {
            return "更新统计数据成功";
        } else {
            return "更新统计数据失败";
        }
    }

    @Override
    public Statistics findStatisticById(int statisticId) throws SQLException {
        return statisticsMapper.findStatisticById(statisticId);
    }

    @Override
    public List<Statistics> findAllStatistics() throws SQLException {
        return statisticsMapper.findAllStatistics();
    }
}